package www.ld.com.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import www.ld.com.domain.R;
import www.ld.com.domain.dto.user.UserInfoDTO;
import www.ld.com.domain.vo.PersonalInfoVO;
import www.ld.com.service.UserService;
import www.ld.com.utils.SecurityUtils;

@Api(tags = "个人信息")
@RestController
@RequestMapping("/personal")
public class PersonalInfoController {
    @Autowired
    private UserService userService;

    @PostMapping("oauth/{username}")
    @ApiOperation(value = "用户名获取用户详情")
    public R<UserInfoDTO> getPersonalByUsername(@PathVariable("username") String username) {
        return R.ok(userService.getUserInfoDTOByUsername(username));
    }


    @GetMapping("personal_info")
    @ApiOperation(value = "获取用户信息")
    public R<PersonalInfoVO> getPersonalInfo() {
        UserInfoDTO userInfoDTO = SecurityUtils.getPersonalInfo();
        return R.ok(userInfoDTO);
    }

}
